﻿<UserControl x:Class="SPIWareMVVM.Views.CustomerList"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:conv="clr-namespace:SPIWareMVVM.Views.Conversions"
			 xmlns:me="clr-namespace:SPIWareMVVM.ViewModels" 
			 mc:Ignorable="d" 
			 d:DesignHeight="300" d:DesignWidth="300">
	<UserControl.Resources>
		<ObjectDataProvider x:Key="customersVM" ObjectType="{x:Type me:CustomersViewModel}"/>
		<conv:BoolToVisibilityConverter x:Key="boolToVis" />
		<!--<Style TargetType="{x:Type FrameworkElement}" x:Key="GridEditStyle">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Visibility" Value="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, 
			 AncestorType={x:Type ListViewItem}}, Converter={StaticResource boolToVis}, ConverterParameter=True}" />
		</Style>-->

	</UserControl.Resources>
	<DockPanel>
		<ToolBar DockPanel.Dock="Top">
			<TextBlock DockPanel.Dock="Top" Text="Customers" Background="Azure" Width="Auto"/>
			<Separator/>
		</ToolBar>
		<ListBox DockPanel.Dock="Left" x:Name="lbCustomers" ItemsSource="{Binding Path=ocCustomers, Source={StaticResource customersVM}, Mode=TwoWay}"
				 SelectionChanged="Customers_SelectionChanged"/>

		<DockPanel x:Name="dpCustomerEdit" DockPanel.Dock="Top" Visibility="Collapsed" DataContext="{Binding SelectedItem, ElementName=lbCustomers}">
			<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
				<TextBlock Text="("/>
				<TextBlock Text="{Binding Path=CustomerId}"/>
				<TextBlock Text=") "/>
				<TextBlock Text="{Binding Path=Name}"/>
			</StackPanel>
			<Grid DockPanel.Dock="Top">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition Height="24"/>
				</Grid.RowDefinitions>
				<TextBlock Grid.Column="0" Grid.Row="0" Text="Name: "/>
				<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Name, Mode=TwoWay}" />
			</Grid>
			<ToolBar DockPanel.Dock="Top">
				<TextBlock DockPanel.Dock="Top" Text="Addresses" Background="Azure" Width="55"/>
				<Separator/>
				<!--<Button Click="AddNewAddress">
					<Image Source="..\Images\plus32.png" Height="32" Width="32" />
				</Button>-->
			</ToolBar>
			<ToolBar DockPanel.Dock="Left" Background="MidnightBlue"/>
			<ListBox DockPanel.Dock="Top" x:Name="lbContactData" ItemsSource="{Binding Path=ocContactInfos}"
				 SelectionChanged="Address_SelectionChanged"/>
			<DockPanel DockPanel.Dock="Top" x:Name="dpAddressEdit" Visibility="Collapsed" DataContext="{Binding SelectedItem, ElementName=lbContactData}">
				<Grid DockPanel.Dock="Top">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="85"/>
						<ColumnDefinition Width="Auto"/>
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<TextBlock Grid.Column="0" Grid.Row="0" Text="Contact Name: "/>
					<TextBlock Grid.Column="0" Grid.Row="1" Text="Address: "/>
					<TextBlock Grid.Column="0" Grid.Row="2" Text="City, ST Zip: "/>
					<TextBlock Grid.Column="0" Grid.Row="3" Text="Country: "/>
					<TextBlock Grid.Column="0" Grid.Row="4" Text="Telephone: "/>
					<TextBlock Grid.Column="0" Grid.Row="5" Text="Fax: "/>

					<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=SelectedItem.Name, ElementName=lbContactData}"/>
					<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1">
						<TextBox Text="{Binding Path=SelectedItem.AddressLine1, ElementName=lbContactData}"/>
						<TextBox Text="{Binding Path=SelectedItem.AddressLine2, ElementName=lbContactData}"/>
					</StackPanel>
					<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal">
						<TextBox Text="{Binding Path=SelectedItem.Locality, ElementName=lbContactData}"/>
						<TextBlock Text=", "/>
						<TextBox Text="{Binding Path=SelectedItem.StateProvince, ElementName=lbContactData}"/>
						<TextBlock Text=" "/>
						<TextBox Text="{Binding Path=SelectedItem.PostalCode, ElementName=lbContactData}"/>
						<TextBlock Text=" - "/>
						<TextBox Text="{Binding Path=SelectedItem.Plus4, ElementName=lbContactData}"/>
					</StackPanel>
					<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=SelectedItem.Country, ElementName=lbContactData}"/>
					<TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=SelectedItem.Telephone, ElementName=lbContactData}"/>
					<TextBox Grid.Column="1" Grid.Row="5" Text="{Binding Path=SelectedItem.Fax, ElementName=lbContactData}"/>
				</Grid>
			</DockPanel>
		</DockPanel>
	</DockPanel>
</UserControl>
